import java.io.IOException;

public class 前缀和基础 {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] nums = new int[n + 100];
        int[] s = new int[n + 100];
        for (int i = 1; i <= n; i++) {
            nums[i] = scan.nextInt();
        }
        //计算前缀和
        for (int i = 1; i <= n; i++) {
            s[i] = s[i - 1] + nums[i];
        }
        int l;
        int r;
        while(m-->0){
            l= scan.nextInt();
            r= scan.nextInt();
            System.out.println(s[r]-s[l-1]);
        }
    }
}

